package com.turing.post.tuxedo.util;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import org.jdom2.Element;

import com.turing.post.util.PCPSApplicationException;

/**
 * 下载商户业务类型输出
 * 
 * @author yxb
 * 
 */
@SuppressWarnings("serial")
public class OBSType extends TransResponse implements Serializable {
	/**
	 * 业务类型数据字典
	 */
	public Map<String, String> allbs = new HashMap<String, String>();

	/**
	 * 产生计算MAC的域
	 */
	@Override
	protected void generateMacField() {
	}

	/**
	 * 构造交易应答私有报文体
	 * 
	 * @param reqBody
	 * @throws Exception
	 */
	@Override
	protected void constructRespBodyXml(Element respBody)
			throws PCPSApplicationException {
		// bs
		TransXmlHelper.addStringElement(respBody,
				TransXmlHelper.XML_NODE_BsTypeCount, allbs.size() + "");
		for (Map.Entry<String, String> entry : allbs.entrySet()) {
			// each bstype
			Element bstype_el = new Element(TransXmlHelper.XML_NODE_BsType);
			TransXmlHelper.addStringElement(bstype_el,
					TransXmlHelper.XML_NODE_BsTypeId, entry.getKey());
			TransXmlHelper.addStringElement(bstype_el,
					TransXmlHelper.XML_NODE_BsTypeName, entry.getValue());
			respBody.addContent(bstype_el);
		}
	}
}
